import random
import time
import urllib.parse
from selenium import webdriver
from selenium.webdriver.edge.options import Options
from tool import mysqlAction

opt = Options()
opt.add_experimental_option('detach', True)
driver = webdriver.Edge(options=opt)
keywordArr = []


def main():
    array = mysqlAction.select_data("tbl_sys_location_city", "provinceId < 32", 0)
    for item in array:
        item_str = urllib.parse.quote(item[2]+"公共资源交易中心")
        url_str = "https://cn.bing.com/search?q=%s&form=APMCS1&PC=APMC" % item_str
        # driver.get(url_str)
        js_str = "window.open('" + url_str + "','_blank');"
        driver.execute_script(js_str)
        time.sleep(30)


if __name__ == "__main__":
    main()
